package com.bosicen.crm.service.sysmanage;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import com.bosicen.crm.dao.entity.Dealer;
import com.bosicen.crm.dao.sysmanage.DealerDao;
import com.bosicen.crm.tools.Page;

import org.springframework.transaction.annotation.Transactional;
/**
 * 经销商信息
 * @author tigerlei
 *
 */
@Service("dealerService")
public class DealerServiceImpl {
	@Autowired
	private DealerDao dealerDao;


	/****
	 * 查询列表
	 * 
	 * @param companyid
	 * @return
	 */
	public List<Dealer> findDealerList(int id) {
		List<Dealer> list = null;
		try {
			list = this.dealerDao.findDealerList(id);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return list;
	}

	/****
	 * 查询列表
	 * @param id
	 * @return
	 */
	
	public Page findDealer4Page(Dealer dealer,Page page) {
		return this.dealerDao.findDealer4Page(dealer, page);
	}
	/***
	 * 新增/修改
	 * 
	 * @param p
	 */
	@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
	public boolean saveOrUpdateDealer(Dealer p) {
		try {
			 this.dealerDao.saveOrUpdate(p);
		} catch (Exception ex) {
			ex.printStackTrace();
			return false;
		}
		return true;
	}

	/****
	 * 按ID查询
	 * 
	 * @param companyid
	 * @return
	 */
	public Dealer findDealerById(int id) {
		Dealer Dealer = null;
		try {
			Dealer = this.dealerDao.findDealerById(id);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return Dealer;
	}

	/****
	 * 删除 
	 * @param p
	 */
	@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
	public boolean delDealer(Dealer p) {
		try {
			this.dealerDao.delDealer(p);
		} catch (Exception ex) {
			ex.printStackTrace();
			return false;
		}
		return true;
	}
	
	

}
